-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added authentication token caching #51
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if err == nil { | ||
spaceClientCache[identifier] = client | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we cover the password rotation for the OrgClient as well?
Motivation
The CF Service Operator currently constructs a new CF Client for every reconcile loop. This means that it has to perform the discovery of the UAA endpoint and the fetching of the token for every reconcile. As these endpoints are unauthenticated, they are subject to stricter rate-limits than the authenticated endpoints, thus leading to a quick exhaustion of the rate limit in the case of many CF resources.
Proposal
This PR proposes a mechanism to cache the CF Client for each combination of API URL and Username (which is guaranteed to identify a unique user), and let the existing oAuth automatic token renewal mechanism of the CF Client renew the token whenever necessary.
Tests
Tests are included to check that the requests are not performed when the CF Client is cached.
Minor additions
I have also changed the secret name of the webhook TLS secret for the local development script, as it did not match that of the helm chart (https://github.com/SAP/cf-service-operator-helm/blob/main/chart/templates/webhook.yaml#L45).